<%@ page language="java" isELIgnored="false" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>列表信息</title>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script>
        function resume_delete(id) {
            var result = confirm("是否删除？");
            if(result){
                // 发送ajax请求
                $.ajax({
                    url: '/resumes/'+id,
                    type: 'DELETE',
                    data: id,
                    contentType: 'application/json;charset=utf-8',
                    dataType: 'json',
                    success: function (data) {
                        window.location.href="resumes";
                    }
                })
            }

        }
        function resume_edit(id) {
            window.location.href="resumes/editForm?id="+id;
        }
        function resume_add() {
            window.location.href="resumes/addForm";
        }
    </script>
</head>
<body>
    <button id="add" name="add" type="button" onclick="resume_add()">新增</button>

<table class="table table-border table-bordered table-bg table-hover table-sort">
    <thead>
    <tr>
        <th>id</th>
        <th>地址</th>
        <th>名字</th>
        <th>电话号码</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${resumes}" var="resume">
        <tr>
            <th>${resume.id}</th>
            <th>${resume.address}</th>
            <th>${resume.name}</th>
            <th>${resume.phone}</th>
            <th>
                <button id="edit" type="button" onclick="resume_edit(${resume.id})">编辑</button>
                <button id="delete" type="button" onclick="resume_delete(${resume.id})">删除</button>
            </th>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>